﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace NewsMine.Utilities
{
    public class SmtpHelper
    {
        public void SendMail()
        {
            using (MailMessage mM = new MailMessage())
            {
                //Mail Address
                mM.From = new MailAddress("from@address.com");
                //receiver email id
                mM.To.Add("email@address.net");
                //subject of the email
                mM.Subject = "More details... " + "Subject";
                //deciding for the attachment
               // mM.Attachments.Add(new Attachment(tempData.GeneratePicturePath));
                //add the body of the email
                mM.Body = "facebook post";
                mM.IsBodyHtml = true;
                //SMTP client
                using (SmtpClient sC = new SmtpClient("smtp.gmail.com"))
                {
                    //port number for Gmail mail
                    sC.Port = 587;
                    //credentials to login in to Gmail account
                    sC.Credentials = new NetworkCredential("username", "password");
                    //enabled SSL
                    sC.EnableSsl = true;
                    //Send an email

                    sC.Send(mM);
                }
            }
        }
    }
}
